package com.xwzn.resident;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.xwzn.resident.adapter.HomeShfwXqAdapter;
import com.xwzn.resident.model.HomeShfwXq;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 生活服务更多界面
 * @Author HanKaiYang
 * @CreateDate 2019/12/23 11:05
 * @Version 1.0
 */
public class ShfwGdActivity extends AppCompatActivity {

    private ImageView ivTitleBack;
    private RecyclerView rlvShfwGd;
    //生活服务详情数据
    private List<HomeShfwXq> homeShfwXqList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shfw_gd);
        initView();
    }

    /**
     * @deprecated 初始化视图
     * @author HanKaiYang
     * @createDate 2019/12/23 11:16
     * @version 1.0
     */
    private void initView() {
        ivTitleBack = (ImageView) findViewById(R.id.iv_title_back);
        ivTitleBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        rlvShfwGd = findViewById(R.id.rlv_shfw_gd);
        homeShfwXqList = new ArrayList<>();
        homeShfwXqList.add(new HomeShfwXq(R.drawable.image_3, "KFC", "2019-12-12 08:57:17", "重庆市KFC总结"));
        final HomeShfwXqAdapter homeShfwXqAdapter = new HomeShfwXqAdapter(this,homeShfwXqList);
        rlvShfwGd.setLayoutManager(new LinearLayoutManager(this));
        rlvShfwGd.setAdapter(homeShfwXqAdapter);
        homeShfwXqAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Intent intent = new Intent(ShfwGdActivity.this, ShfwItemActivity.class);
                intent.putExtra("title",homeShfwXqAdapter.getData().get(position).getTitle());
                intent.putExtra("date",homeShfwXqAdapter.getData().get(position).getDate());
                intent.putExtra("content",homeShfwXqAdapter.getData().get(position).getContent());
                startActivity(intent);
            }
        });
    }

}
